package main

import (
	"github.com/spf13/viper"
	"github.com/sqjian/bingo/pkg/errors"
	"github.com/sqjian/bingo/plugin/proto"
	pluginSchema "github.com/sqjian/bingo/plugin/schema"
	pkgSchema "github.com/sqjian/bingo/tools"
)

type Print struct {
	tool  pkgSchema.Tools
	viper *viper.Viper
}

func (p *Print) Init() errors.Error {
	p.tool.Logger().Infof("%v Init...\n", p.Name())
	return nil
}
func (p *Print) FInit() errors.Error {
	p.tool.Logger().Infof("%v FInit...\n", p.Name())
	return nil
}
func (p *Print) Interest(msg *proto.Msg, tools pkgSchema.Tools) (pluginSchema.Action, errors.Error) {
	return pluginSchema.CONTINUE, nil
}

func (p *Print) PreProcess(msg *proto.Msg, tools pkgSchema.Tools) (pluginSchema.Action, errors.Error) {
	return pluginSchema.CONTINUE, nil
}

func (p *Print) Process(msg *proto.Msg, tools pkgSchema.Tools) (pluginSchema.Action, errors.Error) {
	tools.Logger().Infof("msg:%v\n", msg.String())
	return pluginSchema.CONTINUE, nil
}

func (p *Print) PostProcess(msg *proto.Msg, tools pkgSchema.Tools) (pluginSchema.Action, errors.Error) {
	return pluginSchema.CONTINUE, nil
}

func (p *Print) Name() string {
	return "print"
}
func NewPlugin(viper *viper.Viper, tools pkgSchema.Tools) (pluginSchema.Plugin, errors.Error) {
	return &Print{viper: viper, tool: tools}, nil
}
